From aecd25280fecc186c99a1d96c300e1f02d76da9e Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Sat, 28 May 2005 11:00:01 +0000 Subject: [PATCH] bitkeeper revision 1.1584 (42984f31pkIsDJAxZBlaJgFWP9L2QA) Assembly code cleanups. gcc doesn't need very many hints to get the operand size and register names correct for both x86/32 and x86/64. Signed-off-by: Keir Fraser --- xen/arch/x86/flushtlb.c | 2 +- xen/arch/x86/vmx_vmcs.c | 16 ++-------------- xen/include/asm-x86/bitops.h | 4 ++-- xen/include/asm-x86/flushtlb.h | 2 +- xen/include/asm-x86/processor.h | 30 ++++++++++++++++-------------- xen/include/asm-x86/rwlock.h | 12 ++++++------ 6 files changed, 28 insertions(+), 38 deletions(-) diff --git a/xen/arch/x86/flushtlb.c b/xen/arch/x86/flushtlb.c index 2079bf51c6..5e132a7a14 100644 --- a/xen/arch/x86/flushtlb.c +++ b/xen/arch/x86/flushtlb.c @@ -57,7 +57,7 @@ void write_cr3(unsigned long cr3) */ skip_clocktick: - __asm__ __volatile__ ( "mov"__OS" %0, %%cr3" : : "r" (cr3) : "memory" ); + __asm__ __volatile__ ( "mov %0, %%cr3" : : "r" (cr3) : "memory" ); /* * STEP 3. Update this CPU's timestamp. Note that this happens *after* diff --git a/xen/arch/x86/vmx_vmcs.c b/xen/arch/x86/vmx_vmcs.c index 8f1768602f..a770855c6a 100644 --- a/xen/arch/x86/vmx_vmcs.c +++ b/xen/arch/x86/vmx_vmcs.c @@ -316,11 +316,7 @@ construct_init_vmcs_guest(struct cpu_user_regs *regs, error |= __vmwrite(GUEST_EFLAGS, eflags); error |= __vmwrite(GUEST_INTERRUPTIBILITY_INFO, 0); -#ifdef __i386__ __asm__ __volatile__ ("mov %%dr7, %0\n" : "=r" (dr7)); -#else - __asm__ __volatile__ ("movq %%dr7, %0\n" : "=r" (dr7)); -#endif error |= __vmwrite(GUEST_DR7, dr7); error |= __vmwrite(GUEST_VMCS0, 0xffffffff); error |= __vmwrite(GUEST_VMCS1, 0xffffffff); @@ -356,21 +352,13 @@ static inline int construct_vmcs_host(struct host_execution_env *host_env) host_env->idtr_base = desc.address; error |= __vmwrite(HOST_IDTR_BASE, host_env->idtr_base); -#ifdef __i386__ - __asm__ __volatile__ ("movl %%cr0,%0" : "=r" (crn) : ); -#else - __asm__ __volatile__ ("movq %%cr0,%0" : "=r" (crn) : ); -#endif + __asm__ __volatile__ ("mov %%cr0,%0" : "=r" (crn) : ); host_env->cr0 = crn; error |= __vmwrite(HOST_CR0, crn); /* same CR0 */ /* CR3 is set in vmx_final_setup_hostos */ -#ifdef __i386__ - __asm__ __volatile__ ("movl %%cr4,%0" : "=r" (crn) : ); -#else - __asm__ __volatile__ ("movq %%cr4,%0" : "=r" (crn) : ); -#endif + __asm__ __volatile__ ("mov %%cr4,%0" : "=r" (crn) : ); host_env->cr4 = crn; error |= __vmwrite(HOST_CR4, crn); error |= __vmwrite(HOST_EIP, (unsigned long) vmx_asm_vmexit_handler); diff --git a/xen/include/asm-x86/bitops.h b/xen/include/asm-x86/bitops.h index 5abf8d9cff..fd74c0f2e6 100644 --- a/xen/include/asm-x86/bitops.h +++ b/xen/include/asm-x86/bitops.h @@ -357,7 +357,7 @@ static inline unsigned long __scanbit(unsigned long val, unsigned long max) */ static __inline__ unsigned long find_first_clear_bit(unsigned long word) { - __asm__("bsf"__OS" %1,%0" + __asm__("bsf %1,%0" :"=r" (word) :"r" (~word)); return word; @@ -365,7 +365,7 @@ static __inline__ unsigned long find_first_clear_bit(unsigned long word) static __inline__ unsigned long find_first_set_bit(unsigned long word) { - __asm__("bsf"__OS" %1,%0" + __asm__("bsf %1,%0" :"=r" (word) :"r" (word)); return word; diff --git a/xen/include/asm-x86/flushtlb.h b/xen/include/asm-x86/flushtlb.h index 810bf345b7..17b44fe3ae 100644 --- a/xen/include/asm-x86/flushtlb.h +++ b/xen/include/asm-x86/flushtlb.h @@ -70,7 +70,7 @@ static inline unsigned long read_cr3(void) { unsigned long cr3; __asm__ __volatile__ ( - "mov"__OS" %%cr3, %0" : "=r" (cr3) : ); + "mov %%cr3, %0" : "=r" (cr3) : ); return cr3; } diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h index e054eb22b0..3df0ee6a5d 100644 --- a/xen/include/asm-x86/processor.h +++ b/xen/include/asm-x86/processor.h @@ -255,24 +255,24 @@ static inline unsigned int cpuid_edx(unsigned int op) #define read_cr0() ({ \ unsigned long __dummy; \ __asm__( \ - "mov"__OS" %%cr0,%0\n\t" \ + "mov %%cr0,%0\n\t" \ :"=r" (__dummy)); \ __dummy; \ }) #define write_cr0(x) \ - __asm__("mov"__OS" %0,%%cr0": :"r" ((unsigned long)x)); + __asm__("mov %0,%%cr0": :"r" ((unsigned long)x)); #define read_cr4() ({ \ unsigned long __dummy; \ __asm__( \ - "mov"__OS" %%cr4,%0\n\t" \ + "mov %%cr4,%0\n\t" \ :"=r" (__dummy)); \ __dummy; \ }) #define write_cr4(x) \ - __asm__("mov"__OS" %0,%%cr4": :"r" ((unsigned long)x)); + __asm__("mov %0,%%cr4": :"r" ((unsigned long)x)); /* * Save the cr4 feature set we're using (ie @@ -284,22 +284,24 @@ extern unsigned long mmu_cr4_features; static inline void set_in_cr4 (unsigned long mask) { + unsigned long dummy; mmu_cr4_features |= mask; - __asm__("mov"__OS" %%cr4,%%"__OP"ax\n\t" - "or"__OS" %0,%%"__OP"ax\n\t" - "mov"__OS" %%"__OP"ax,%%cr4\n" - : : "irg" (mask) - :"ax"); + __asm__ __volatile__ ( + "mov %%cr4,%0\n\t" + "or %1,%0\n\t" + "mov %0,%%cr4\n" + : "=&r" (dummy) : "irg" (mask) ); } static inline void clear_in_cr4 (unsigned long mask) { + unsigned long dummy; mmu_cr4_features &= ~mask; - __asm__("mov"__OS" %%cr4,%%"__OP"ax\n\t" - "and"__OS" %0,%%"__OP"ax\n\t" - "mov"__OS" %%"__OP"ax,%%cr4\n" - : : "irg" (~mask) - :"ax"); + __asm__ __volatile__ ( + "mov %%cr4,%0\n\t" + "and %1,%0\n\t" + "mov %0,%%cr4\n" + : "=&r" (dummy) : "irg" (~mask) ); } /* diff --git a/xen/include/asm-x86/rwlock.h b/xen/include/asm-x86/rwlock.h index 7519f32713..e8c8846cb5 100644 --- a/xen/include/asm-x86/rwlock.h +++ b/xen/include/asm-x86/rwlock.h @@ -35,10 +35,10 @@ "js 2f\n" \ "1:\n" \ ".section .text.lock,\"ax\"\n" \ - "2:\tpush"__OS" %%"__OP"ax\n\t" \ - "lea"__OS" %0,%%"__OP"ax\n\t" \ + "2:\tpush %%"__OP"ax\n\t" \ + "lea %0,%%"__OP"ax\n\t" \ "call " helper "\n\t" \ - "pop"__OS" %%"__OP"ax\n\t" \ + "pop %%"__OP"ax\n\t" \ "jmp 1b\n" \ ".previous" \ :"=m" (*(volatile int *)rw) : : "memory") @@ -65,10 +65,10 @@ "jnz 2f\n" \ "1:\n" \ ".section .text.lock,\"ax\"\n" \ - "2:\tpush"__OS" %%"__OP"ax\n\t" \ - "lea"__OS" %0,%%"__OP"ax\n\t" \ + "2:\tpush %%"__OP"ax\n\t" \ + "lea %0,%%"__OP"ax\n\t" \ "call " helper "\n\t" \ - "pop"__OS" %%"__OP"ax\n\t" \ + "pop %%"__OP"ax\n\t" \ "jmp 1b\n" \ ".previous" \ :"=m" (*(volatile int *)rw) : : "memory") -- 2.30.2